package com.foreknow.elmboot.mapper;

import com.foreknow.elmboot.po.DeliveryAddress;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface DeliveryAddressMapper {
    @Select("select * from deliveryaddress where userId=#{userId} order by daId")
    public List<DeliveryAddress> listDeliveryAddressByUserId(String userId);

    /**
     * 根据daId查询一个对象
     * @param daId
     * @return
     */
    @Select("select * from deliveryaddress where daId=#{daId}")
    public DeliveryAddress getDeliveryAddressById(Integer daId);

    /**
     * 添加
     * @param deliveryAddress
     * @return
     */
    @Insert("insert into deliveryaddress(contactName,contactSex,contactTel,address,userId)value(#{contactName},#{contactSex},#{contactTel},#{address},#{userId})")
    public int saveDeliveryAddress(DeliveryAddress deliveryAddress);

    /**
     * 修改
     * @param deliveryAddress
     * @return
     */
    @Update("update deliveryaddress set contactName=#{contactName},contactSex=#{contactSex},contactTel=#{contactTel},address=#{address} where userId=#{userId}")
    public int updateDeliveryAddress(DeliveryAddress deliveryAddress);

    /**
     *
     * @param daId
     * @return
     */


    @Delete("delete from deliveryaddress where daId=#{daId}")
    public int removeDeliveryAddress(Integer daId);
}
